# 获取当前CMakeLists.txt文件所在目录的完整路径
set(CURRENT_CMAKELIST_DIR "${CMAKE_CURRENT_SOURCE_DIR}")

# 获取当前目录的名称
get_filename_component(CURRENT_DIR_NAME ${CURRENT_CMAKELIST_DIR} NAME)

# 输出目录名称
message(STATUS "Current CMakeLists directory name: ${CURRENT_DIR_NAME}")

set(TARGET ${CURRENT_DIR_NAME})
#dubug -g 调试 GBK 中文
# set (CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -g -fexec-charset=GBK")
# 设置源代码文件的编码为UTF-8
set(CMAKE_CHARSET "UTF-8")
 
# 设置编译器选项以支持UTF-8
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -finput-charset=UTF-8")
  
# 设置算法库的导出与安装路径！！！
set(CMAKE_INSTALL_BINDIR ${SRC_ROOT_DIR}/install_files/YuA/bin)
set(CMAKE_INSTALL_LIBDIR ${SRC_ROOT_DIR}/install_files/YuA/lib)
set(CMAKE_INSTALL_EXPDIR ${SRC_ROOT_DIR}/install_files/YuA/lib)
set(CMAKE_INSTALL_INCLUDEDIR ${SRC_ROOT_DIR}/install_files/YuA)
set (_yuA_CMake_BINDIR ${CMAKE_INSTALL_BINDIR})
set (_yuA_CMake_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR})
set (_yuA_CMake_LIBDIR ${CMAKE_INSTALL_LIBDIR})
set (_yuA_CMake_EXPDIR ${CMAKE_INSTALL_EXPDIR})
set (_yuA_CMake_INSTALLDIR ${_yuA_CMake_LIBDIR}/cmake/yFile)

SET(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib") 

FILE(GLOB SOURCES_FILES "./*.cpp")
FILE(GLOB HEADER_FILES "./*.h")
FILE(GLOB_RECURSE EXP_FILES "${CMAKE_CURRENT_BINARY_DIR}/*.exp")

ADD_LIBRARY(${TARGET} SHARED ${HEADER_FILES} ${SOURCES_FILES})
set_target_properties(${TARGET} PROPERTIES FOLDER "services") #将此工程分类到文件夹中
set_target_properties(${TARGET} PROPERTIES
  DEBUG_POSTFIX "_d"
  RELEASE_POSTFIX "")
  
set_target_properties (${TARGET} PROPERTIES PUBLIC_HEADER "${HEADER_FILES}")
# # 链接 OpenCV 库
# target_link_libraries(${TARGET} PUBLIC
    # # ${OPENCV_LIB_DIR}/opencv_world480d.lib
    # #Qt${QT_VERSION_MAJOR}::Core
# )

# 为共享库添加导出定义
# 对于 Windows 平台，使用 __declspec(dllexport) 来标记导出符号
if(WIN32)
  target_compile_definitions(${TARGET} PRIVATE EXPORTDLL_EXPORTS)
endif()

# 对于非 Windows 平台，使用 __attribute__((visibility("default"))) 来标记导出符号
if(NOT WIN32)
  set_target_properties(${TARGET} PROPERTIES CXX_VISIBILITY_PRESET hidden)
  set_target_properties(${TARGET} PROPERTIES VISIBILITY_INLINES_HIDDEN ON)
  target_compile_options(${TARGET} PRIVATE -fvisibility=hidden)
endif()


# set_target_properties(${TARGET} PROPERTIES FOLDER "dll") #将此工程分类到文件夹中

# 安装库到指定路径！
install (TARGETS ${TARGET}
  EXPORT yBasic-targets
  RUNTIME DESTINATION ${_yuA_CMake_BINDIR}
  PUBLIC_HEADER DESTINATION ${_yuA_CMake_INCLUDE_DIR}/include/yFile
  LIBRARY DESTINATION ${_yuA_CMake_LIBDIR}
  ARCHIVE DESTINATION ${_yuA_CMake_LIBDIR})

# install(FILES
 # ${EXP_FILES}
 # COMPONENT runtime
 # DESTINATION ${_yuA_CMake_EXPDIR})